

	
		
	***********************************************************************************
	***	What Should I Aspire to? Peer Effects in Adolescents’ Friendship Networks	***
	*** Ben D'Exelle, Rik Habraken & Arjan Verschoor								***
	***	April 2022																	***
	***********************************************************************************
	
	
	*open datafile
	use peer_effects_in_aspirations.dta, clear

	
	*Settings 
	graph set window fontface "Times New Roman"
	ssc inst catplot	// install user-written catplot command

	
	
	
	
	********************************************************************	
	* Table 1. Descriptive statistics of socioeconomic characteristics *
	********************************************************************
	 
	 eststo clear

	estpost tabstat location gender totalsiblings low_educ_bothpar 					///
		bothparentsalive bagisu religion_bornagain religion_islam caring_for_others	///
		sports romantic_partner tv_important internet_important						///
		fatherimportantincome2 motherimportantincome2 fatherimportantincome1		///
		motherimportantincome1 percentage_friends number_of_reportedfriends			///
		if included==1, statistics(mean sd) columns(statistics)			

	
	
	**************************************************************
	* Table 2. Competition, aspiration weights and outspokenness *
	**************************************************************
	
		*column 1
		ttest conflict_pair1=3 if included==1
		ttest conflict_pair2=3 if included==1
		ttest conflict_pair3=3 if included==1
		
	
		*column 2
		ttest outspoken_pair1=0 if included==1
		ttest outspoken_pair2=0 if included==1
		ttest outspoken_pair3=0 if included==1

		*column 3
		ttest pair1=5 if included==1
		ttest pair2=5 if included==1		
		ttest pair3=5 if included==1
		
		* column 4
		spearman conflict_pair1 outspoken_pair1 if included==1
		spearman conflict_pair2 outspoken_pair2 if included==1
		spearman conflict_pair3 outspoken_pair3 if included==1		
		
		* column 5
		spearman conflict_pair1 pair1 if included==1
		spearman conflict_pair2 pair2 if included==1
		spearman conflict_pair3 pair3 if included==1
		
		
	***********************************************************************************************
	* Table 3. Comparison of absolute distance in aspirations and competition, by dyadic relation *
	***********************************************************************************************
	
	
	*aspiration scores
	ttest dyad_dist_asp_pair1_random = dyad_dist_asp_pair1_friend  		// random vs friend
	ttest dyad_dist_asp_pair1_random = dyad_dist_asp_pair1_nofr  		// random vs non-friend
	ttest dyad_dist_asp_pair1_nofr = dyad_dist_asp_pair1_friend    		// non-friend vs friend

	ttest dyad_dist_asp_pair2_random = dyad_dist_asp_pair2_friend  		// random vs friend
	ttest dyad_dist_asp_pair2_random = dyad_dist_asp_pair2_nofr  		// random vs non-friend
	ttest dyad_dist_asp_pair2_nofr = dyad_dist_asp_pair2_friend    		// non-friend vs friend

	ttest dyad_dist_asp_pair3_random = dyad_dist_asp_pair3_friend  		// random vs friend
	ttest dyad_dist_asp_pair3_random = dyad_dist_asp_pair3_nofr  		// random vs non-friend
	ttest dyad_dist_asp_pair3_nofr = dyad_dist_asp_pair3_friend    		// non-friend vs friend

		
	

	
	
	*conflict scores
	ttest dyad_dist_confl_pair1_random = dyad_dist_confl_pair1_friend	// random vs friend
	ttest dyad_dist_confl_pair1_random = dyad_dist_confl_pair1_nofr 	// random vs non-friend
	ttest dyad_dist_confl_pair1_nofr = dyad_dist_confl_pair1_friend  	// non-friend vs friend

	ttest dyad_dist_confl_pair2_random = dyad_dist_confl_pair2_friend	// random vs friend
	ttest dyad_dist_confl_pair2_random = dyad_dist_confl_pair2_nofr 	// random vs non-friend
	ttest dyad_dist_confl_pair2_nofr = dyad_dist_confl_pair2_friend  	// non-friend vs friend
	
	ttest dyad_dist_confl_pair3_random = dyad_dist_confl_pair3_friend	// random vs friend
	ttest dyad_dist_confl_pair3_random = dyad_dist_confl_pair3_nofr 	// random vs non-friend
	ttest dyad_dist_confl_pair3_nofr = dyad_dist_confl_pair3_friend  	// non-friend vs friend
	
	
	
	
	
	
	
	****************************************	
	* Table 4. Peer effects in aspirations *
	****************************************
	
		
		* Macro for exogenous characteristics
		global exlist religion_bornagain religion_islam wealth gender totalsiblings 	///
				low_educ_bothpar bothparentsalive sports caring_for_others				///
				romantic_partner tv_important internet_important bagisu loc_control 	///
				fatherimportantincome2 motherimportantincome2 fatherimportantincome1	///
				motherimportantincome1 fatherimportantincome3 motherimportantincome3	///
				religion_bornagain_tie1 religion_islam_tie1 wealth_tie1 gender_tie1 	///
				totalsiblings_tie1 low_educ_bothpar_tie1 bothparentsalive_tie1			///
				sports_tie1 caring_for_others_tie1 romantic_partner_tie1				///
				tv_important_tie1 internet_important_tie1 bagisu_tie1					///
				loc_control_tie1 fatherimportantincome2_tie1 							///
				motherimportantincome2_tie1	fatherimportantincome1_tie1	 				///
				motherimportantincome1_tie1	fatherimportantincome3_tie1 				///
				motherimportantincome3_tie1				
				
				
		* Macro for instruments
		global inslist low_educ_bothpar_excl_peer wealth_excl_peer	
		
		* Regression results 
		xtset class_n
		
		foreach i of num 1 2 3 {
			
			* Linear regression
			xtreg pair`i' pair`i'_tie1 $exlist  if included==1, fe i(class_n)  r			
			
			* 2SLS
			xtivreg2 pair`i' $exlist (pair`i'_tie1 = $inslist) if included==1, r		///
				fe i(class_n) endog(pair`i'_tie1) 
			
			* GMM
			xtivreg2 pair`i' $exlist (pair`i'_tie1 = $inslist) if included==1, 			///
				gmm2s r fe i(class_n) endog(pair`i'_tie1) 	
		}
	
	
	* t-test in Section 5.2 on comparing the reportred number of friends in the classroom with the number of friends on other classes. 
	ttest number_of_reportedfriends = friendsotherclasses if included==1

	* t-test in Section 5.3 on the propoprtion of friends who engage in sports, by whether or not the individual engages in sports. 
	ttest  sports_tie1 if included==1, by(sports)

	
	***************************************	
	* Table 5. Heterogeneous peer effects *
	***************************************
		
	foreach v of varlist  sports bagisu totalsiblings {
		
		*drop previously generated interaction variables
		capture drop TO1_tie1_interaction wealth_excl_peer_int low_ed_bothp_excl_peer_int

		*generate interaction variable between endogenous regressor and exogenous characteristic
		gen TO1_tie1_interaction = pair1_tie1 *  `v'

		*generate interaction variable between instrument and exogenous characteristic	
		gen wealth_excl_peer_int = wealth_excl_peer *  `v'
		gen low_ed_bothp_excl_peer_int = low_educ_bothpar_excl_peer *  `v'

		* IV estimation results (GMM)
		xtivreg2 pair1 $exlist `v' `v'_tie1 (pair1_tie1 							///
			TO1_tie1_interaction= low_educ_bothpar_excl_peer 						///
			low_ed_bothp_excl_peer_int wealth_excl_peer_int wealth_excl_peer)		///
			if included==1, gmm2s r fe i(class_n)  endog(pair1_tie1 				///
			TO1_tie1_interaction) partial($exlist `v'_tie1)
						
	}		
			
			
			
	
	
	
	**********************************************************************************	
	* Figure A.1. Distribution of the percentage of classmates identified as friends *
	**********************************************************************************

	twoway histogram percentage_friends if included==1, freq width(10)  			///
		graphregion(color(gs16))													///
		xlabel(0(10)100, nogrid) ylabel(0(50)250, glcolor(gs15)) xtitle("") 		///
		ytitle("Frequency") b2title("Percentage of classmates as friends") 			///
		subtitle("") color(gs10) lcolor(gs16)
	
	
	************************************************		
	* Figure A.2. Distribution of friends by class *
	************************************************

	graph box number_of_reportedfriends if included==1,over(rural_based, 			///
		label(labsize(small))) over(class_n, 										///
		label(labsize(small))) graphregion(color(white))  							///
		title("", color(gs0) height(7) 												///
		size(medlarge))   															///
		asyvar box(1, color(gs10)) box(2, color(gs5)) 								///
		marker(1, mcolor(gs10)) marker(2, mcolor(gs5))								///
		ylabel(0(5)65, 																///
		angle(h) labsize(medsmall) format(%9.0f))									///
		ytitle("Number of reported friends in class", height(7) size(medium))		///
		legend(cols(5) order(1 "Urban-based" 2 "Rural-based") 						///
		region(col(white)) position(6) bmargin(medium) size(small)) 
		
	
	
	graph box percentage_friends if included==1,over(rural_based, 					///
		label(labsize(small))) over(class_n, 										///
		label(labsize(small))) graphregion(color(white))  							///
		title("", color(gs0) height(7) 												///
		size(medlarge))   															///
		asyvar box(1, color(gs10)) box(2, color(gs5)) 								///
		marker(1, mcolor(gs10)) marker(2, mcolor(gs5))								///
		ylabel(0(10)100, 															///
		angle(h) labsize(medsmall) format(%9.0f))									///
		ytitle("% of students in class reported as friend", height(7) size(medium))	///
		legend(cols(5) order(1 "Urban-based" 2 "Rural-based") 						///
		region(col(white)) position(6) bmargin(medium) size(small)) 	

		
	************************************************************************************
	* Figure A.3. Distribution of aspirations, perceived competition and outspokenness *
	************************************************************************************

	distplot pair1 pair2 pair3 if included==1, trscale(100*@) 						///
		lc(gs2 gs7 gs10) lpattern( shortdash dash solid) xscale () 					///
		xtitle("Aspiration weight",  margin(t=2)) ytitle("Percent", margin(r=2)) 	///
		graphregion(color(gs16)) xlabel(0(1)10, labsize(small)) ylabel(0(10)100, 	///
		glcolor(gs15) labsize(small)) legend(pos(6) col(3) 							///
		label(1 "Pair 1 - peaceful relations") label(2 "Pair 2 - proximity") 		///
		label(3 "Pair 3 - community") nobox region(lstyle(none)) size(small)) 
		
		
	distplot conflict_pair1 conflict_pair2 conflict_pair3 if included==1, 			///
		trscale(100 * @) lc(gs2 gs7 gs10) 											///
		lpattern( shortdash dash solid) xscale () xtitle("Level of competition",  	///
		margin(t=2)) ytitle("Percent", margin(r=2)) graphregion(color(gs16)) 		///
		xlabel(1(1)5, labsize(small)) ylabel(0(10)100, glcolor(gs15) 				///
		labsize(small)) legend(pos(6) col(3) label(1 "Pair 1 - peaceful relations")	///
		label(2 "Pair 2 - proximity") label(3 "Pair 3 - community") nobox 			///
		region(lstyle(none)) size(small))
		
	distplot outspoken_pair1 outspoken_pair2 outspoken_pair3 if included==1, 		///
		trscale(100 * @) lc(gs2 gs7 gs10) lpattern( shortdash dash solid) xscale ()	///
		xtitle("Level of outspokenness", margin(t=2)) ytitle("Percent", 			///
		margin(r=2)) graphregion(color(gs16)) xlabel(0(1)5) ylabel(0(10)100, 		///
		glcolor(gs15) labsize(small)) legend(pos(6) col(3) 							///
		label(1 "Pair 1 - peaceful relations") label(2 "Pair 2 - proximity") 		///
		label(3 "Pair 3 - community") nobox region(lstyle(none)) size(small)) 

	
	************************************************************************	
	* Figure A.4. Perceived competition by outspokenness about aspirations * 
	************************************************************************
	
	catplot conflict_pair1_new outspoken_pair1 if included==1,  					///
		percent(outspoken_pair1) asyvars stack bar(1, bcolor(gs6))   				///
		bar(2, bcolor(gs8)) bar(3, bcolor(gs10)) bar(4, bcolor(gs12)) 				///
		bar(5, bcolor(gs14))  														///
		subtitle(Outspokenness pair 1 (0-5) - peaceful relations) 					///
		ylabel(, labsize(msmall)) ytitle("Percent", margin(t=2)) legend(pos(6) 		///
		col(2) nobox region(lstyle(none)) size(small)) graphregion(color(white))
		
	catplot conflict_pair2_new outspoken_pair2 if included==1, 						///
		percent(outspoken_pair2) asyvars stack bar(1, bcolor(gs6)) 					///
		bar(2, bcolor(gs8)) bar(3, bcolor(gs10)) bar(4, bcolor(gs12)) 				///
		bar(5, bcolor(gs14)) 														///
		subtitle(Outspokenness pair 2 (0-5) - proximity family/friends) 			///
		ylabel(, labsize(msmall)) ytitle("Percent", margin(t=2)) legend(pos(6) 		///
		col(2) nobox region(lstyle(none)) size(small)) graphregion(color(white))

	catplot conflict_pair3_new outspoken_pair3 if included==1, 						///
		percent(outspoken_pair3) asyvars stack bar(1, bcolor(gs6)) 				 	///
		bar(2, bcolor(gs8)) bar(3, bcolor(gs10)) bar(4, bcolor(gs12)) 				///
		bar(5, bcolor(gs14)) 														///
		subtitle(Outspokenness pair 3 (0-5) - community engagement) 				///
		ylabel(, labsize(msmall)) ytitle("Percent", margin(t=2)) legend(pos(6) 		///
		col(2) nobox region(lstyle(none)) size(small)) graphregion(color(white))

		
	******************************************************************************
	* Figure A.5. Perceived competition by weight assigned to paired aspirations *
	******************************************************************************

	catplot conflict_pair1_new pair1 if included==1, percent(pair1) asyvars			///
		stack bar(1, bcolor(gs6)) bar(2, bcolor(gs8)) bar(3, bcolor(gs10)) bar(4, 	///
		bcolor(gs12)) bar(5, bcolor(gs14)) 											///
		subtitle(Aspiration weights pair 1 (0-10) - peaceful relations) 			///
		ylabel(, labsize(msmall)) ytitle("Percent", margin(t=2)) legend(pos(6) 		///
		col(2) nobox region(lstyle(none)) size(small)) graphregion(color(white))

	catplot conflict_pair2_new pair2 if included==1, percent(pair2) asyvars			///
		stack bar(1, bcolor(gs6)) bar(2, bcolor(gs8)) bar(3, bcolor(gs10)) bar(4, 	///
		bcolor(gs12)) bar(5, bcolor(gs14)) 											///
		subtitle(Aspiration weights pair 2 (0-10) - proximity family/friends) 		///
		ylabel(, labsize(msmall)) ytitle("Percent", margin(t=2)) legend(pos(6) 		///
		col(2) nobox region(lstyle(none)) size(small)) graphregion(color(white))

	catplot conflict_pair3_new pair3 if included==1, percent(pair3) asyvars			///
		stack bar(1, bcolor(gs6)) bar(2, bcolor(gs8)) bar(3, bcolor(gs10)) bar(4, 	///
		bcolor(gs12)) bar(5, bcolor(gs14)) 											///
		subtitle(Aspiration weights pair 3 (0-10) - community engagement) 			///
		ylabel(, labsize(msmall)) ytitle("Percent", margin(t=2)) legend(pos(6) 		///
		col(2) nobox region(lstyle(none)) size(small)) graphregion(color(white))

		
	******************************		
	* Figure A.6. Network graphs *
	******************************
	
		/*
		
		Based on different datasets per class. See seperate do-file labelled: network_graphs.do
		
		*/
			
	
	
	*******************************************************************************	
	* Table A.1. Correlation between the characteristics of ego and ego’s friends *
	*******************************************************************************
	
		*column 1
		estpost tabstat gender totalsiblings low_educ_bothpar bothparentsalive		///
			 bagisu religion_bornagain religion_islam caring_for_others				///
			sports romantic_partner tv_important internet_important					///
			fatherimportantincome2 motherimportantincome2 							///
			fatherimportantincome1 motherimportantincome1 percentage_friends		///
			number_of_reportedfriends if included==1, statistics(mean sd) 			///
			columns(statistics)			
		
		*column 2		
		estpost tabstat gender_tie1 totalsiblings_tie1 low_educ_bothpar_tie1 		///
			bothparentsalive_tie1 bagisu_tie1 religion_bornagain_tie1  				///
			religion_islam_tie1 caring_for_others_tie1  sports_tie1   				///
			romantic_partner_tie1 tv_important_tie1 internet_important_tie1 		///
			fatherimportantincome2_tie1 motherimportantincome2_tie1					///
			fatherimportantincome1_tie1 motherimportantincome1_tie1					///
			percentage_friends_tie1 num_reportedfriends_tie1 if included==1,		///
			statistics(mean sd) columns(statistics)			
		
		*column 3
		spearman gender gender_tie1 if included==1
		pwcorr totalsiblings totalsiblings_tie1 if included==1, sig
		spearman low_educ_bothpar low_educ_bothpar_tie1 if included==1
		spearman bothparentsalive bothparentsalive_tie1 if included==1
		spearman bagisu bagisu_tie1 if included==1
		spearman religion_bornagain religion_bornagain_tie1 if included==1
		spearman religion_islam religion_islam_tie1 if included==1
		spearman caring_for_others caring_for_others_tie1 if included==1
		spearman sports sports_tie1 if included==1
		spearman romantic_partner romantic_partner_tie1 if included==1
		spearman tv_important tv_important_tie1 if included==1
		spearman internet_important internet_important_tie1 if included==1
		spearman fatherimportantincome2 fatherimportantincome2_tie1 if included==1
		spearman motherimportantincome2 motherimportantincome2_tie1 if included==1
		spearman fatherimportantincome1 fatherimportantincome1_tie1 if included==1
		spearman motherimportantincome1 motherimportantincome1_tie1 if included==1
		pwcorr percentage_friends percentage_friends_tie1 if included==1, sig
		pwcorr number_of_reportedfriends num_reportedfriends_tie1 if included==1, sig
			
	
	
	*************************************************************************************
	* Table A.2. Descriptive statistics on the mean aspiration weights of ego’s friends *
	*************************************************************************************	
	
	su pair1_tie1 pair2_tie1 pair3_tie1 if included==1

	
	
	**************************************************************************	
	* Table A.3. Differences with students without friends or excluded peers *	
	**************************************************************************
	
	*characteristics by students with and without friends/excluded peers
	estpost tabstat pair1 pair2 pair3 conflict_pair1								///
		conflict_pair2 conflict_pair3 religion_bornagain religion_islam wealth 		///
		gender totalsiblings low_educ_bothpar bothparentsalive sports				///
		caring_for_others romantic_partner  										///
		tv_important internet_important bagisu loc_control 							///
		fatherimportantincome2 motherimportantincome2								///
		fatherimportantincome1 motherimportantincome1 								///
		fatherimportantincome3 motherimportantincome3,	statistics(mean sd) 		///
		columns(statistics)	by(included)	

	
	*test for differences: continuous variables
	estpost ttest pair1 pair2 pair3 conflict_pair1 conflict_pair2 					///
		conflict_pair3 totalsiblings wealth loc_control, by(included)	

	*test for differences: categorical variables	
	estpost prtest religion_bornagain religion_islam gender low_educ_bothpar 		///
		bothparentsalive sports caring_for_others romantic_partner tv_important 	///
		internet_important bagisu fatherimportantincome2 motherimportantincome2		///
		fatherimportantincome1 motherimportantincome1 fatherimportantincome3		///
		motherimportantincome3, by(included) 		
		
	
	
	
	************************************************
	* Table A.4. Determinants of aspirations (OLS) *
	************************************************
	
	foreach i of num 1 2 3 {
		
		xtreg pair`i' pair`i'_tie1 $exlist if included==1, fe i(class_n)  r			
	}	
			

	*******************************************************
	* Table A.5. Full first stage results 2SLS estimation *
	*******************************************************

	foreach i of num 1 2 3 {
		
		xtreg pair`i'_tie1 $inslist $exlist if included==1, fe i(class_n) r
	}
		
		
	*******************************************************************
	* Table A.6. Weak instrument robust tests for IV estimation (GMM) *
	*******************************************************************

		foreach i of num 1 2 3 {
	
		qui xtivreg2 pair`i' $exlist (pair`i'_tie1 = $inslist) if included==1,			///
			gmm2s r fe i(class_n) endog(pair`i'_tie1) 
			weakiv	
		}
		
		
	********************************************************************************************
	* Table A.7. Peer effects with controls for perceived competition of ego and ego’s friends *
	********************************************************************************************

	foreach i of num 1 2 3 {

		*Linear regression
		xtreg pair`i' pair`i'_tie1 conflict_pair`i' conflict_pair`i'_tie1  $exlist if 	///
			included==1, fe i(class_n)  r		

		*2SLS		
		xtivreg2 pair`i' $exlist conflict_pair`i' conflict_pair`i'_tie1 				///
			(pair`i'_tie1 = $inslist) if included==1, r fe i(class_n) 					///
			endog(pair`i'_tie1) partial ($exlist conflict_pair`i' conflict_pair`i'_tie1)
		
		*GMM						
		xtivreg2 pair`i' $exlist conflict_pair`i' conflict_pair`i'_tie1					///
			(pair`i'_tie1 = $inslist) if included==1, gmm2s r fe i(class_n) 			///
			endog(pair`i'_tie1) partial($exlist conflict_pair`i' conflict_pair`i'_tie1)
	}
	
	
	*************************************************************	
	* Table A.8. Peer effects in perceived level of competition *
	*************************************************************		
		
	foreach i of num 1 2 3 {
		
		*Linear regression
		xtreg conflict_pair`i' conflict_pair`i'_tie1 $exlist if included==1, 			///
			fe i(class_n) r		
		
		*2SLS
		xtivreg2 conflict_pair`i' $exlist (conflict_pair`i'_tie1 = $inslist) 			///
			if included==1, r fe i(class_n) endog(conflict_pair`i'_tie1) partial($exlist)
		
		*GMM
		xtivreg2 conflict_pair`i' $exlist (conflict_pair`i'_tie1 = $inslist)			///
			if included==1,	gmm2s r fe i(class_n) endog(conflict_pair`i'_tie1)			///
			partial($exlist)			
	}
			
			
	***************************************************************					
	* Table A.9. Endogenous peer effects with competition weights *
	***************************************************************		

	foreach i of num 1 2 3 {
			
		*2SLS - no weights
		xtivreg2 pair`i' $exlist (pair`i'_tie1 = $inslist) if included==1, r			///
			fe i(class_n) endog(pair`i'_tie1) partial($exlist)
			
		*2SLS - weights
		xtivreg2 pair`i' $exlist (pair`i'_tie1 = $inslist) 								///
			[pweight=conflict_pair`i'] if included==1, r fe i(class_n) 					///
			endog(pair`i'_tie1) partial($exlist) 

		*GMM - no weights
		xtivreg2 pair`i' $exlist (pair`i'_tie1 = $inslist) if included==1,				///
			gmm2s r fe i(class_n) endog(pair`i'_tie1)  partial($exlist)
		
		*GMM - weights			
		xtivreg2 pair`i' $exlist (pair`i'_tie1 = $inslist) 								///
			[pweight=conflict_pair`i'] if included==1, gmm2s r fe i(class_n) 			///
			endog(pair`i'_tie1) partial($exlist) 				
		}	 
	
	
	************************************************************************		
	* Table A.10. Heterogeneous peer effects: Perceived competition of ego *
	************************************************************************	
		
		*drop previously generated interaction variables
		capture drop TO1_tie1_interaction TO2_tie1_interaction TO3_tie1_interaction
		
		* interact conflict of ego with endogenous regressor
		gen TO1_tie1_interaction = pair1_tie1 *  conflict_pair1
		gen TO2_tie1_interaction = pair2_tie1 *  conflict_pair2
		gen TO3_tie1_interaction = pair3_tie1 *  conflict_pair3
		
		* interact conflict of ego with instruments (per pair)
		gen wealth_excl_peer_int1 = wealth_excl_peer *  conflict_pair1
		gen low_ed_bothp_excl_peer_int1 = low_educ_bothpar_excl_peer *  conflict_pair1
		gen wealth_excl_peer_int2 = wealth_excl_peer *  conflict_pair2
		gen low_ed_bothp_excl_peer_int2 = low_educ_bothpar_excl_peer *  conflict_pair2
		gen wealth_excl_peer_int3 = wealth_excl_peer *  conflict_pair3
		gen low_ed_bothp_excl_peer_int3 = low_educ_bothpar_excl_peer *  conflict_pair3		
		
		
		* IV estimation (GMM)
		foreach i of num 1 2 3  {
		
		xtivreg2 pair`i' $exlist conflict_pair`i' conflict_pair`i'_tie1					///
			(pair`i'_tie1 TO`i'_tie1_interaction= low_educ_bothpar_excl_peer			///
			low_ed_bothp_excl_peer_int`i' wealth_excl_peer_int`i' 						///
			wealth_excl_peer) if included==1, gmm2s r fe i(class_n)  					///
			endog(pair`i'_tie1 TO`i'_tie1_interaction) partial($exlist 					///
			conflict_pair`i'_tie1)			
		}	
			
			
	**********************************************************************************		
	* Table A.11. Heterogeneous peer effects: Perceived competition of ego’s friends *
	**********************************************************************************		
	
		*drop previously generated interaction variables
		capture drop TO1_tie1_interaction TO2_tie1_interaction TO3_tie1_interaction		///
			wealth_excl_peer_int wealth_excl_peer_int3 wealth_excl_peer_int4 			///
			wealth_excl_peer_int5 low_ed_bothp_excl_peer_int 							///
			low_ed_bothp_excl_peer_int3 low_ed_bothp_excl_peer_int4 					///
			low_ed_bothp_excl_peer_int5

		*generate the interaction variables between aspirations of ego's friends and conflict of ego's friends
		gen TO1_tie1_interaction = pair1_tie1 *  conflict_pair1_tie1
		gen TO2_tie1_interaction = pair2_tie1 *  conflict_pair2_tie1	
		gen TO3_tie1_interaction = pair3_tie1 *  conflict_pair3_tie1
		
		*generate the interaction variables between instruments and conflict of ego's friends	
		gen wealth_excl_peer_int1 = wealth_excl_peer *  conflict_pair1_tie1
		gen low_ed_bothp_excl_peer_int1 = low_educ_bothpar_excl_peer *  conflict_pair1_tie1

		gen wealth_excl_peer_int2 = wealth_excl_peer *  conflict_pair2_tie1
		gen low_ed_bothp_excl_peer_int2 = low_educ_bothpar_excl_peer *  conflict_pair2_tie1

		gen wealth_excl_peer_int3 = wealth_excl_peer *  conflict_pair3_tie1
		gen low_ed_bothp_excl_peer_int3 = low_educ_bothpar_excl_peer *  conflict_pair3_tie1		
			
			
		*IV estimation (GMM)	
		foreach i of num 1 2 3  {
			
			xtivreg2 pair`i' $exlist conflict_pair`i' conflict_pair`i'_tie1 			///
				(pair`i'_tie1 TO`i'_tie1_interaction= low_educ_bothpar_excl_peer 		///
				low_ed_bothp_excl_peer_int`i' wealth_excl_peer_int`i' 					///
				wealth_excl_peer) if included==1, gmm2s r fe i(class_n)  				///
				endog(pair`i'_tie1 TO`i'_tie1_interaction) partial($exlist conflict_pair`i')
							
			}		
				

	**********************************************************************************
	* Table A.12. Peer effects in aspirations: Controlling for the number of friends *		
	**********************************************************************************

	foreach i of num 1 2 3 {
		
		xtivreg2 pair`i' $exlist number_of_reportedfriends 								///
			num_reportedfriends_tie1 (pair`i'_tie1 = $inslist) if included==1, gmm2s	///
			r fe i(class_n) endog(pair`i'_tie1) partial($exlist)
					
		}
		
		
	
	
	
		
	// END OF DO-FILE
	
	
	
	
	
	
*******************************************************************************************************************************	
*******************************************************************************************************************************	
*******************************************************************************************************************************	
	
	
	
	
